//
//  playViewController.m
//  FingerUniversity
//
//  Created by vantle on 16/3/23.
//  Copyright © 2016年 vantle. All rights reserved.
//

#import "playViewController.h"
#import "MobClick.h"
#import "SVProgressHUD.h"
#define ScreenHeight [UIScreen mainScreen].bounds.size.height
#define ScreenWidth [UIScreen mainScreen].bounds.size.width
@interface playViewController ()

@end
@implementation playViewController
- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    
    [MobClick beginLogPageView:@"playViewController"];//("PageOne"为页面名称，可自定义)
}
- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    [MobClick endLogPageView:@"playViewController"];
}
-(void)viewDidLoad
{
    self.view.backgroundColor=[UIColor whiteColor];

    
    UIImageView*barImage=[[UIImageView alloc]initWithFrame:CGRectMake(0, 20, ScreenWidth, 44)];
    barImage.userInteractionEnabled=YES;
    barImage.backgroundColor=[UIColor colorWithRed:0.92 green:0.92 blue:0.92 alpha:1];
    [self.view addSubview:barImage];
    
    UIButton*backButton=[UIButton buttonWithType:UIButtonTypeCustom];
    backButton.frame=CGRectMake(0, 0, 100, 44);
    [backButton addTarget:self action:@selector(backButtonClick) forControlEvents:UIControlEventTouchUpInside];
    [barImage addSubview:backButton];
    
    UIImageView*backImage=[[UIImageView alloc]initWithFrame:CGRectMake(5, 12, 5, 20)];
    backImage.image=[UIImage imageNamed:@"back_arrowleft"];
    [barImage addSubview:backImage];
    
    UIImageView*logoImage=[[UIImageView alloc]initWithFrame:CGRectMake(backImage.frame.origin.x+backImage.frame.size.width+3, 6, 32, 32)];
    logoImage.layer.cornerRadius=3;
    logoImage.clipsToBounds=YES;
    logoImage.image=[UIImage imageNamed:@"app-logo-80"];
    [barImage addSubview:logoImage];
    
    UILabel* noticeLabel=[[UILabel alloc]initWithFrame:CGRectMake(logoImage.frame.origin.x+logoImage.frame.size.width+5, 10, 100, 25)];
    noticeLabel.text=@"课程详情";
    [barImage addSubview:noticeLabel];
    
    [self load];
    
}
-(void)load
{
    NSString *encodedString = (NSString *)
    CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault,
                                                              (CFStringRef)self.url,
                                                              (CFStringRef)@"!$&'()*+,-./:;=?@_~%#[]",
                                                              NULL,
                                                              kCFStringEncodingUTF8));
   
        UIWebView*webView=[[UIWebView alloc]initWithFrame:CGRectMake(0, 64, ScreenWidth, ScreenHeight-64)];
        webView.scalesPageToFit = YES;
        [webView setDelegate:self];
        NSURL* url =[NSURL URLWithString:encodedString];
        NSURLRequest* request = [NSURLRequest requestWithURL:url];
        [self.view addSubview:webView];
        [webView loadRequest:request];
    
}
- (void)webViewDidStartLoad:(UIWebView *)webView
{
    [SVProgressHUD show];
}
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
    [SVProgressHUD dismiss];
}
-(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    return UIInterfaceOrientationLandscapeLeft;
}

- (NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskLandscape;
}
-(void)backButtonClick
{
    [self.navigationController popViewControllerAnimated:YES];
}
@end
    
